const { DataTypes } = require('sequelize');
const sequelize = require('../config/database');
const User = require('./User');

// 定义求职意向模型
const JobIntention = sequelize.define('JobIntention', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  userId: {
    type: DataTypes.INTEGER,
    allowNull: false,
    references: {
      model: User,
      key: 'id'
    },
    onUpdate: 'CASCADE',
    onDelete: 'CASCADE'
  },
  jobType: {
    type: DataTypes.ENUM('full-time', 'part-time', 'internship'),
    allowNull: false
  },
  industry: {
    type: DataTypes.STRING,
    allowNull: false
  },
  position: {
    type: DataTypes.STRING,
    allowNull: false
  },
  location: {
    type: DataTypes.STRING,
    allowNull: false
  },
  salaryExpectation: {
    type: DataTypes.STRING,
    allowNull: false
  },
  description: {
    type: DataTypes.TEXT
  },
  status: {
    type: DataTypes.ENUM('active', 'inactive'),
    defaultValue: 'active'
  }
}, {
  timestamps: true,
  underscored: true,
  tableName: 'job_intentions'
});

// 关联用户
User.hasOne(JobIntention);
JobIntention.belongsTo(User);

module.exports = JobIntention;